<form action="<?=site_url(array('c' => 'cms_news','m' => 'add_newsletter'))?>" method="post" id="newsletterForm">
<table class="form-table" cellpadding="5" cellspacing="0" style="width: 100%;">
	<tbody>
		<tr>
			<th>Title: </th>
	    	<td><input type="text" name="newsletter_name" class="input-text required" value=""/></td>
	    </tr>
		<tr>
	    	<th>Group: </th>
	    	<td>
				<select name="newsletter_gid" class="input-text required">
					<option value="">Please select</option>
					<?php foreach($groups as $item):?>
					<option value="<?=$item['id']?>">
						<?=$item['name']?>
					</option>
					<?php endforeach;?>
				</select>
			</td>
	    </tr>
		<tr>
	    	<th>Picture: </th>
	    	<td>
	    		<input type="text" id="newsletter_img" name="newsletter_img" class="input-text" value="">
				<input id="newsletter_img_btn" name="img_btn" type="button" class="" value="..." />
	    	</td>
	    </tr>
	    <tr>
	    	<th>Caption: </th>
	    	<td><input type="text" name="newsletter_caption" value="" class="input-text"></td>
	    </tr>
	    <tr>
	    	<th>Brief: </th>
	    	<td><textarea name="newsletter_brief" rows="7" cols="37" class="input-textarea"></textarea></td>
	    </tr>
	    <tr>
	    	<th>Description: </th>
	    	<td><textarea name="newsletter_description" rows="7" cols="37" class="input-textarea"></textarea></td>
	    </tr>
	    <tr>
	    	<th>Post Date: </th>
	        <td>
	        	<input type="text" id="postdate" name="newsletter_postdate" class="input-text required date" value="<?=date('Y-m-d')?>" maxlength="10">
	        </td>
		</tr>
	</tbody>
</table>
</form>
<script type="text/javascript">
$("#postdate").datepicker({dateFormat: 'yy-mm-dd'});

var finder = new CKFinder();
finder.BasePath = '/system/plugins/ckfinder/';
finder.SelectFunction = SetFileFieldNewImg;
$("#newsletter_img_btn").bind("click", function(){
	finder.Popup();
});
function SetFileFieldNewImg(fileUrl) {
	$('#newsletter_img').val(fileUrl);
}
</script>